<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  		<title><fmt:message key="policyList.heading"/></title>
  		<script type="text/javascript">
  		$(function() {
  			applyDate("datepicker1");
			applyDate("datepicker");
			});
  		</script>
  </head>
  <body>	
			<ul>
	  <li class="titleonly"><img src="${ctxPath}/css/style/base/image/dot.gif" width="15" height="16" class="dot" />&gt;&gt;政策管理</li>
	</ul>
	<ul style="text-align:center;">
		<li class="searchinfo_inform"><a href="editPolicy.do?type=1"><img src="${ctxPath}/css/style/base/image/plus.gif" align="absmiddle"/> 普通政策添加</a> &nbsp;&nbsp;&nbsp;&nbsp;
			<a href="editPolicy.do?type=2"><img src="${ctxPath}/css/style/base/image/plus.gif" align="absmiddle"/> 特价政策添加</a> &nbsp;&nbsp;&nbsp;&nbsp;
			<a href="editPolicy.do?type=3"><img src="${ctxPath}/css/style/base/image/plus.gif" align="absmiddle"/> 特殊政策添加</a> &nbsp;&nbsp;&nbsp;&nbsp;
			<a href="policys.do?cmd=goBatchUpload"><img src="${ctxPath}/css/style/base/image/plus.gif" align="absmiddle"/> 批量政策添加</a> &nbsp;&nbsp;&nbsp;&nbsp;
		</li>
	</ul>
        <ul>
        <form action="policys.do" method="get" id="tableForm" name="tableForm">
        <table width="700" border="0" cellspacing="0" cellpadding="0" class="dd">
		  <tr>
		  	<td>政策号：</td>
			<td> <input name="Q_policyCode_S_EQ" type="text" class="inputbox120" value="${param['Q_policyCode_S_EQ']}"/></td>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		  </tr>
		  <tr>
			<td>舱位代码：</td>
			<td> <input name="Q_cabin_S_LK" type="text" class="inputbox120" value="${param['Q_cabin_S_LK']}"/></td>
			<td>航司代码：</td>
			<td><input name="Q_flightCode_S_EQ" type="text" class="inputbox120"  value="${param['Q_flightCode_S_EQ']}"/></td>
		  </tr>
		  <tr>
			<td>起飞城市：</td>
			<td> <input name="Q_dpt_S_EQ" type="text" class="inputbox120"  value="${param['Q_dpt_S_EQ']}"/></td>
			<td>到达城市：</td>
			<td><input name="Q_arr_S_EQ" type="text" class="inputbox120"  value="${param['Q_arr_S_EQ']}"/></td>
		  </tr>
		  <tr>
			<td>销售日期：</td>
			<td> <input name="Q_startdateTicket_D_GE" type="text" class="inputbox120" id="datepicker1" value="${param['Q_startdateTicket_D_GE']}"/></td>
			<td>旅行日期：</td>
			<td><input name="Q_startDate_D_GE" type="text" class="inputbox120" id="datepicker" value="${param['Q_startDate_D_GE']}"/></td>
		  </tr>
		  <tr>
		   <td>政策类型：</td>
			<td> <select name="Q_policyType_L_EQ" class="inputbox120">
						  <option value="" selected="selected">全部政策</option>
						  <option value="1"  <c:if test="${param['Q_policyType_L_EQ']==1}">selected="selected"</c:if> >普通政策</option>
						  <option value="2" <c:if test="${param['Q_policyType_L_EQ']==2}">selected="selected"</c:if>>特价政策</option>
						  <option value="3" <c:if test="${param['Q_policyType_L_EQ']==3}">selected="selected"</c:if>>申请产品</option>
						  <option value="4" <c:if test="${param['Q_policyType_L_EQ']==4}">selected="selected"</c:if>>包机切位</option>
						  <option value="5" <c:if test="${param['Q_policyType_L_EQ']==5}">selected="selected"</c:if>>预付产品</option>
							</select></td>
			<td>政策状态：</td>
			<td> <select name="Q_status_L_EQ" class="inputbox120">
						  <option value="1" <c:if test="${param['Q_status_L_EQ']==1}">selected="selected"</c:if>>有效</option>
						  <!-- <option value="2">挂起</option>
						  <option value="3">删除</option> -->
						  <option value="0" <c:if test="${param['Q_status_L_EQ']==0}">selected="selected"</c:if>>无效</option>
						  <option value="2" <c:if test="${param['Q_status_L_EQ']==2}">selected="selected"</c:if>>挂起</option>
							</select></td>
			</tr>
		  <tr>
			<td colspan="6" style="text-align:center"><input name="Submit" type="submit" class="inputsubmit" value="查询" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     
			 <input name="Submit2" type="reset" class="inputsubmit" value="重置" onClick="this.form.reset();"/></td>
			</tr>
		</table>
		</form>
	</ul>
  </div>
  <div id="right">
	<ul>
	  <li>
	  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td class="titleonly">&gt;&gt;国内航司政策列表</td>
			<!-- <td align="right" class="titleonly_1"><a href="#">&gt;&gt;普通政策</a> &nbsp;&nbsp;&nbsp;&nbsp;
			<a href="#">&gt;&gt;特价政策</a> &nbsp;&nbsp;&nbsp;&nbsp;
			<a href="#">&gt;&gt;特殊政策</a>&nbsp;&nbsp;&nbsp;&nbsp;
			
			</td> -->
		  </tr>
		</table>
    </li>
	</ul>
	<ul>
	  <li>
	  
	  
	 		 <c:set var="checkAll">
	  			<input type="checkbox" name="ckAll" onclick="checkAll(this,'policyId');"/>
	  		</c:set>
		    	<display:table name="policys" sort="external" pagesize="${policys.objectsPerPage}"
			    	cellpadding="0" cellspacing="0" style="width:100%" export="false" 
			    	id="policyItem" partialList="true" size="${policys.fullListSize}" requestURI="policys.do">
			    	<display:column title="${checkAll}" media="html" style="width:8px;align:center">
				  		<input type="checkbox" name="policyId" value="${policyItem.policyId}">
				  	</display:column>
				<display:column property="flightCode" titleKey="航司" sortName="flightCode" sortable="false" class="tableinfo center" />  
				<display:column titleKey="起飞</br>到达" class="tableinfo center" >
					${policyItem.dpt}</br>${policyItem.arr}
				</display:column>  
				<display:column property="flightNumLimit" titleKey="policy.flightNumLimit" sortName="flightNumLimit" sortable="false" class="tableinfo center" >
					<c:if test="${policyItem.flightNumLimit==1}">所有</c:if>
					<c:if test="${policyItem.flightNumLimit==3}">适用</c:if>
					<c:if test="${policyItem.flightNumLimit==2}">不适用</c:if>
				</display:column>   
				<display:column property="cabin" titleKey="舱位" sortName="cabin" sortable="false" class="tableinfo center" /> 
				<display:column titleKey="政策类型" class="tableinfo center" >
						<c:if test="${policyItem.policyType==1}">普通</c:if>
					<c:if test="${policyItem.policyType==2}">特价</c:if>
					<c:if test="${policyItem.policyType==4}">包机</c:if>
					<c:if test="${policyItem.policyType==3}">申请</c:if>
					<c:if test="${policyItem.policyType==5}">预付</c:if>
				</display:column> 	
				<display:column titleKey="政策状态" class="tableinfo center" >
					<c:if test="${policyItem.status==1}">有效</c:if>
					<c:if test="${policyItem.status==0}">无效</c:if>
					<c:if test="${policyItem.status==2}">挂起</c:if>
				</display:column> 	
				<display:column titleKey="旅行有效期" class="tableinfo center" >
					<fmt:formatDate value="${policyItem.startDate}" pattern="yyyy-MM-dd"/></br>
					<fmt:formatDate value="${policyItem.endDate}" pattern="yyyy-MM-dd"/>
				</display:column>
				<display:column titleKey="销售有效期" class="tableinfo center" >
					<fmt:formatDate value="${policyItem.startdateTicket}" pattern="yyyy-MM-dd"/></br>
					<fmt:formatDate value="${policyItem.enfdateTicket}" pattern="yyyy-MM-dd"/>
				</display:column>
				<display:column property="beforeValidDay" titleKey="出票天数" sortName="beforeValidDay" sortable="false" class="tableinfo center" />  
				<display:column  titleKey="policy.discountValue" sortable="false" class="tableinfo center" >
					<c:if test="${policyItem.discountType==4}">
						${policyItem.discountValue}
					</c:if>
					<c:if test="${policyItem.discountType==3}">
						${policyItem.yDiscount}
					</c:if>
					<c:if test="${policyItem.discountType!=4 && policyItem.discountType!=3}">
						/
					</c:if>
				</display:column>  
				<display:column  titleKey="policy.policyCode" sortName="policyCode" sortable="false" class="tableinfo center" >
					<c:if test="${not empty policyItem.policyCode}">
						${policyItem.policyCode}
					</c:if>
					<c:if test="${empty policyItem.policyCode}">
						/
					</c:if>
				</display:column>  
					<display:column media="html" title="管理" class="tableinfo center" >
						<a href="editPolicy.do?policyId=${policyItem.policyId}&type=${policyItem.policyType}" >
						<img src="${ctxPath}/css/style/base/image/amend.gif" width="10" height="10" class="amen"/>修改</a>
						<a href="policys.do?cmd=viewDetail&policyId=${policyItem.policyId}" ><img src="${ctxPath}/css/style/base/image/open.gif" width="10" height="10" class="del"/>查看</a>
						<a href="#"  onclick="deleteObj('policyId',${policyItem.policyId})">删除</a>
					</display:column>
				 </display:table>	
	  </li>
	</ul>
	<ul>
	  <li class="page">&nbsp;&nbsp;
	  	<input name="Submit" type="button" class="inputsubmit" value="挂起" onclick="changeStatus(2,'policyId')"/>
		<input name="Submit" type="button" class="inputsubmit" value="解挂" onclick="changeStatus(3,'policyId')"/>
		<input name="Submit" type="button" onclick="multiDelete('policyId');"  class="inputsubmit" value="勾选删除" />
	 	<input name="Submit" type="button" onclick="deleteAll();"  class="inputsubmit" value="全部删除" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	  </li>
	</ul>
	<script type="text/javascript">
	
	function deleteAll(){
		if(confirm("是否要删除全部正政策?")){
			var url=__ctxPath+"/admin/order/policys.do?cmd=deleteAll";
				$.ajax({
					type : "post",
					url : url,
					dataType : "String",
					contentType: "charset=UTF-8", 
					async:false,
					success : function(flag) {
						if(flag=='fail'){
							alert('删除政策失败');
						}if(flag=='success'){
							alert('删除政策成功');
							location.reload();
						}
					},
					error : function() {
						alert('删除政策失败');
					}
				});
		}
	}
	
	function changeStatus(status,ckName){
		var cks=document.getElementsByName(ckName);
		var isSelected=false;

		for(var i=0;i<cks.length;i++){
			if(cks[i].checked){
				isSelected=true;
				break;
			}
		}
		var tip="";
		if(status==2){
			tip="确定要挂起选择的政策吗?";
		}if(status==3){
			tip="确定要解挂选择的政策吗?";
		}
		if(isSelected){
			if(confirm(tip)){
			var url=__ctxPath+"/admin/order/policys.do?cmd=changPolicyStatus&status="+status;
				for(var k=0;k<cks.length;k++){
					if(cks[k].checked){
						url+="&"+ckName+"="+cks[k].value;
					}
				}
				$.ajax({
					type : "post",
					url : url,
					dataType : "String",
					contentType: "charset=UTF-8", 
					async:false,
					success : function(flag) {
						if(flag=='fail'){
							alert('修改政策状态失败');
						}if(flag=='success'){
							alert('修改政策状态成功');
							location.reload();
						}
					},
					error : function() {
						alert('修改政策状态失败');
					}
				});
		}}else{
			alert("请选择要修改的政策");
		}
		}
	</script>
	</body>
</html>